//
//  LJJBuyCarNoDataView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/22.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJBuyCarNoDataView.h"

@interface LJJBuyCarNoDataView ()

@property (strong, nonatomic) UIImageView *backImageView;    /** 图片 **/
@property (strong, nonatomic) UILabel *hitLabel;    /** 提示文字 **/
@property (strong, nonatomic) UIButton *button;    /** 逛一逛的按钮 **/

@end

@implementation LJJBuyCarNoDataView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = MAINCOLOR;
        [self addSubview:self.backImageView];
        [self addSubview:self.hitLabel];
        [self addSubview:self.button];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [_backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.mas_centerX);
        make.top.equalTo(weakSelf);
        make.size.mas_equalTo(CGSizeMake(172, 139));
    }];
    [_hitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.backImageView.mas_bottom).offset(10);
        make.centerX.equalTo(weakSelf.mas_centerX);
        make.left.right.equalTo(weakSelf);
    }];
    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.hitLabel.mas_bottom).offset(10);
        make.centerX.equalTo(weakSelf.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(120, 50));
    }];
}
#pragma mark -
#pragma mark - method
- (void)buttonMethod:(UIButton *)sender
{
    if (_shoppingBlock) {
        _shoppingBlock();
    }
}
#pragma mark -
#pragma mark - lazy method
- (UIImageView *)backImageView
{
    if (!_backImageView) {
        _backImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"购物车界面静态购物车图标"]];
    }
    return _backImageView;
}
- (UILabel *)hitLabel
{
    if (!_hitLabel) {
        _hitLabel = [[UILabel alloc] init];
        _hitLabel.font = [UIFont systemFontOfSize:14.0];
        _hitLabel.textColor = RGB(53, 161, 241, 1);
        _hitLabel.text = @"购物车还是空的，快去挑选宝贝吧!";
        _hitLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _hitLabel;
}
- (UIButton *)button
{
    if (!_button) {
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        [_button setImage:[UIImage imageNamed:@"购物车界面逛一逛按钮"] forState:UIControlStateNormal];
        [_button addTarget:self action:@selector(buttonMethod:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button;
}

@end
